
//#include "LWP.h"
//#include "impl.h"

#include "LWP/Simple.h"
#include "LWP/UserAgent.h"

#include <iostream>
#include <string>

using namespace std;


using namespace LWP;
using namespace HTTP;

void testmethod()
{
	RequestObject req("www.localhost.com/index.html");
	req.add_header("user-agent", "LWP");
	req.add_header("None", "x");
	req.remove_header("None");
	req.add_data("key", "haha");
	req.add_data("name", "！@##￥%");
//	cout<<req.head()<<"##########\n";
//	cout<<req.get()<<"##########\n";
	//It seems that there is a bug.
//	cout<<req.post()<<"##########\n";
	cout<<req.to_string()<<"##########\n";
}

void test()
{


	HttpHeader header;
	header.add_header("Connection", "keep-alive");
	header.add_header("Keep-Alive", "300");

	HttpForm form;
	form.add_data("user", "kneo");
	form.add_data("title", "");
	form.add_data("title2", "");
	form.add_data("title3", "");
	form.add_data("day", "1");
	form.add_data("day2", "9999");
	form.add_data("flag", "1");

/*
	UserAgent ua;
	ua.agent("Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.8.1) Gecko/20061010 Firefox/2.0");
//	ResponseObject resp = ua.get("www.sina.com.cn", header);
	ResponseObject resp = ua.post("bbs.nju.edu.cn/bbsfind", header);
	cout<<resp.get_data()<<endl;
*/	
}


void testpost()
{
	RequestObject req("www.localhost.com/index.html", HttpRequestType::POST);
	req.content("user=kneo");
	cout<<req.to_string();
}

void teststatus()
{
	UserAgent ua;
	ResponseObject resp = ua.get("www.google.com");
	cout<<resp.status_line()<<"^"<<endl;
	cout<<resp.status_code()<<"^"<<endl;
}

int main()
{
	
	teststatus();

	return 0;
}

